import React from 'react';
import { Table, Icon } from 'antd';

let List = React.createClass({
    handleTableChange(pagination){
    
        const pager = this.props.pagination;
        pager.current = pagination.current;
        pager.currentPage = pagination.current;
       
        this.props.getPagination('2',pager)
    },
    rowKey(data){
        return data.id;
    },
    render() {
        const columns = [
            {
                title: '房源地址',
                dataIndex: 'address',
                key: 'address',
            },
            {
                title: '融资类型',
                dataIndex: 'type',
                key: 'type',
                render: (text, record) => {
                    const financeType = {
                        '101': '收房贷',
                        '102': '装修贷',
                        '103': '租约贷'
                    }
                    return (
                        <span>{financeType[record.type]}</span>
                    )
                }
            },
            {
                title: '租约期限',
                dataIndex: 'contractPeriod',
                key: 'contractPeriod',
            },
            {
                title: '租约起止时间',
                dataIndex: 'amount',
                key: 'amount',
                render: (text, record) => <span>{record.startTime}&nbsp;至&nbsp;{record.endTime}</span>,
            },
            {
                title: '租金(元)',
                dataIndex: 'rent',
                key: 'rent',
            },
            {
                title: '资金方',
                dataIndex: 'capitalName',
                key: 'capitalName',
            },
            
        ];
        return (
            <Table rowKey={this.rowKey}
             columns={columns} 
             dataSource={this.props.dataList}
             pagination={this.props.pagination}
             onChange={this.handleTableChange} />
        )
    }
});

export default List